<%@ page pageEncoding="UTF-8"%>
<%@ taglib prefix="isperp" uri="/WEB-INF/tlds/isperp.tld"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>

<script type="text/javascript">
	function serviceCatalogSelector_afterSelected(rows) {
		var ids = rows[0].id;
		for ( var i = 1; i < rows.length; i++) {
			var item = rows[i];
			ids = ids + "," + item.id;
		}
		//异步创建服务目录
		$.post("project/service/saveServices", {
			projectId : '${projectId}',
			serviceIds : ids
		}, function(data) {
			serviceGrid.reload();//刷新已选
		});
	}

	function createServiceCatalog() {
		isperp.openDialog({
			"contentUrl" : "serviceCatalog/service/edit"
		})
	}

	function serviceGridActions(rowObject) {

		return isperp.createGridAction({
			title : '转派人员',
			iconCls : 'ui-icon-pencil',
			onclick : "isperp.openDialog({contentUrl:'serviceCatalog/service/edit?id=" + rowObject.id + "'})"
		});

	}
</script>
<div class="grid_12" style="margin: 0;width:100%">

	<input type="hidden" id="serviceCatalogSelectorIds">
	<isperp:listSelector id="serviceCatalogSelector" showClearBtn="false"
		displayValueCssClass="hidden" selectorCssClass="hidden"
		showPager="false"
		url="project/service/selectList?projectId=${projectId }"
		afterSelected="serviceCatalogSelector_afterSelected(rows);"
		multiselect="true">


		<isperp:column name="id" title="id" hidden="true"></isperp:column>
		<isperp:column name="code" title="编号" width="80">
		</isperp:column>
		<isperp:column name="name" title="名称" width="100">
		</isperp:column>

		<isperp:column name="serviceWay" title="服务方式" width="80">
		</isperp:column>
		<isperp:column name="serviceResponse" title="服务响应" width="80">
		</isperp:column>

	</isperp:listSelector>
	<isperp:grid url="project/service/listDetail?projectId=${projectId }"
		gridTitle="已选服务目录" gridId="serviceGrid" pager="servicePager"
		idFieldName="entityid" showSearchbar="false" showPager="false"
		cusFormatterActions="true" multiselect="false" actionsWidth="90"
		cusActions="serviceGridActions(rowObject);"
		cusDeleteUrl="project/service/delete">
		<jsp:attribute name="toolbar">
			<isperp:toolbar id="serviceGridToolbar">
			<isperp:button id="serviceGridCreate" icon="icon-plus" text="新建服务目录"
					onclick="createServiceCatalog();"></isperp:button>
			
			<isperp:button id="serviceGridAdd" icon="icon-plus" text="选择服务目录"
					onclick="$('#serviceCatalogSelector').click();"></isperp:button>
			</isperp:toolbar>
		</jsp:attribute>
		<jsp:body>
		
	
		<isperp:column name="entityid" title="entityid" hidden="true"></isperp:column>
		<isperp:column name="id" title="id" hidden="true"></isperp:column>
		<isperp:column name="code" title="编号" width="70">
		</isperp:column>
		<isperp:column name="name" title="名称" width="120">
		</isperp:column>

		<isperp:column name="service_way" title="服务方式" width="70">
		</isperp:column>
		<isperp:column name="service_response" title="服务响应" width="60">
		</isperp:column>
		<isperp:column name="pricing_model" title="计价模式" width="70">
		</isperp:column>
		<isperp:column name="release_date" title="发布日期" width="80">
		</isperp:column>
		<isperp:column name="status" title="状态" width="60">
		</isperp:column>
		</jsp:body>
	</isperp:grid>

</div>
